<!-- 失败补发管理 -->
<template>
<div class="content-box">
  <FilterBox
    :labelWidth="120"
    :filterItemList="filterItemList"
    :filterData="filterData"
    @search="search"
    @clear="clear"
    @keep="keepHeaderList"
  >
  </FilterBox>
  <MyTable
    :gridOptions="{checkboxConfig:{checkField: 'checked', trigger: 'row', highlight: true}}"
    :tableColumn="tableColumn"
    :tableData="tableData"
    :isOrder="false"
    @sendCheckBoxList="setCheckBox"
    >
    <template v-slot:content="scope">
      <div v-if="scope.config.typeTemplate=='html'" v-html="scope.row[scope.config.prop]"></div>
            <span v-else>{{scope.row[scope.config.prop]}}</span>
    </template>
  </MyTable>
  <!-- 分页组件 -->

  <Pagination
    :currentPage="pageinfo.page"
    :pageSize="pageinfo.limit"
    :total="pageinfo.number_all"
    :page_all="pageinfo.page_all"
    @pagination="SetPagination"
    @sendPushButton="pushButton"
  >
  </Pagination>

  <EnterNumber
    ref="enterNumber"
    @success="getTableData"
  >
  </EnterNumber>
</div>
</template>

<script>
import EnterNumber from './FailedReissueManagement_enterNumber'
export default {
  components: {
    EnterNumber
  },
  data(){
    return{
      filterItemList:[
        // input输入框
        { label:this.$t('ExpressCargoManagementLang.Express_Number'),width:200, filterKey: 'express_sn', filterType: 'SearchInput', placeholderStr: null },
        // input输入框
        { label:this.$t('ExpressCargoManagementLang.Package_number'),width:200, filterKey: 'package_sn', filterType: 'SearchInput', placeholderStr: null },
        // 日期选择器
        { label:this.$t('ExpressCargoManagementLang.Failed_time'),width:200, filterKey: 'date', filterType: 'SearchDate' },
        // 下拉框
        { label:this.$t('ExpressCargoManagementLang.Origin'),width:200, filterKey: 'start_local', filterType: 'SearchFilterSelect', placeholderStr: null, filterOptions: {options:[],label:'name',value:'uid'} },
        // 下拉框
        { label:this.$t('ExpressCargoManagementLang.destination'),width:200, filterKey: 'target_local', filterType: 'SearchSelect', placeholderStr: null, filterOptions: {options:[],label:'name',value:'id'} },
      ],
      filterData:{
        page: "",
        limit: "30",
        order: "",

        
        express_sn: "",
        package_sn: "",
        date:[],
        date1: "",
        date2: "",
        start_local: "",
        target_local: "",
        type:1,
      },
      localoptionsStr:[],
      localoptionsEnd:[],
      tableColumn: [
        {
          checked: true,
          label: "",
          prop: "table_code",
          width:40,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Origin'),
          prop: "str_city",
          width:140,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.destination'),
          prop: "end_city",
          width:140,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Package_number'),
          prop: "package_number",
          width:140,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Express_Number'),
          prop: "mailNo",
          width:100,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.weight'),
          prop: "weight",
          width:100,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Length'),
          prop: "long",
          width:80,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Width'),
          prop: "wide",
          width:80,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Height'),
          prop: "high",
          width:80,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.volume'),
          prop: "volume",
          width:100,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Name_consignee'),
          prop: "name",
          width:100,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.pickup_person_phone_number'),
          prop: "telePhone",
          width:100,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Failed_time'),
          prop: "addtime_date",
          width:140,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.Failed_text'),
          prop: "description",
          width:300,
          typeTemplate:'html'
        },
      ],
      tableData: [],

      pageinfo: {
        page: 1,
        page_all: 1,
        limit: 30,
        number_all: 0,
      },
      sendDataArr:[],//多选框勾选集合
    }
  },
  computed: {
      tabsId() {
          return this.$store.state.tabsId;
      }
  },
  mounted(){
    this.getOptionsList()
    this.getHeaderList()
    this.getTableData()
  },
  methods:{
    // 获取下拉单列表
    async getOptionsList() {
      await this.$get("visibleAddress").then((res) => {
        this.localoptionsStr = res.data.start_local;
        this.localoptionsEnd = res.data.all_target_local;
      });
      this.filterItemList=[
        // input输入框
        { label:this.$t('ExpressCargoManagementLang.Express_Number'),width:200, filterKey: 'express_sn', filterType: 'SearchInput', placeholderStr: null },
        // input输入框
        { label:this.$t('ExpressCargoManagementLang.Package_number'),width:200, filterKey: 'package_sn', filterType: 'SearchInput', placeholderStr: null },
        // 日期选择器
        { label:this.$t('ExpressCargoManagementLang.Failed_time'),width:200, filterKey: 'date', filterType: 'SearchDate' },
        // 下拉框
        { label:this.$t('ExpressCargoManagementLang.Origin'),width:200, filterKey: 'start_local', filterType: 'SearchFilterSelect', placeholderStr: null, filterOptions: {options:this.localoptionsStr,label:'name_current',value:'id'} },
        // 下拉框
        { label:this.$t('ExpressCargoManagementLang.destination'),width:200, filterKey: 'target_local', filterType: 'SearchSelect', placeholderStr: null, filterOptions: {options:this.localoptionsEnd,label:'name_current',value:'id'} },
      ]
    },
    //查询
    search(){
      this.getTableData()
    },
    //清空
    clear(){
      this.filterData.express_sn= "",
      this.filterData.package_sn= "",
      this.filterData.date=[],
      this.filterData.date1= "",
      this.filterData.date2= "",
      this.filterData.start_local= "",
      this.filterData.target_local= "",
      this.getTableData()
    },
    // 获取表头组
    getHeaderList(){
      this.$get("get_th",{menu_id:this.tabsId}).then((res) => {
        if(!!res.data.th_json){
          this.tableColumn=JSON.parse(res.data.th_json)
        }
      });
    },
    //保存表头表头组
    keepHeaderList(){
        let params = new FormData();
        params.append("menu_id", this.tabsId);
        params.append("th_json", JSON.stringify(this.tableColumn));
        this.$postForm("save_th", params).then((res) => {
          
        });
    },
    // 更改分页
    SetPagination(data){
      this.filterData.page=data.page
      this.filterData.limit=data.limit
      this.pageinfo.page=data.page
      this.pageinfo.limit=data.limit
      this.getTableData()
    },
    pushButton(route) {
      if (route == "reissue") {
        if (JSON.stringify(this.sendDataArr) == "[]") {
          this.$message.warning(this.$t('common.message_warn_text'));
        } else {
            this.$confirm(this.$t('ExpressCargoManagementLang.sure_reissue'), this.$t('common.prompt'), {
                confirmButtonText: this.$t('common.confirm'),
                cancelButtonText: this.$t('common.cancel'),
            }).then(() => {
                let str=this.sendDataArr.map((obj)=>{return ""+obj.id}).join(",")
                let params = new FormData();
                params.append("ids", str);
                this.$postForm("resetPushOrder", params).then((res) => {
                  if(res.success){
                    this.$message.success(res.msg);
                    this.getTableData();
                  }
                });
            }).catch(() => {});
        }
      }else if (route == "del") {
        if (JSON.stringify(this.sendDataArr) == "[]") {
          this.$message.warning(this.$t('common.message_warn_text'));
        } else {
            this.$confirm(this.$t('ExpressCargoManagementLang.sure_del'), this.$t('common.prompt'), {
                confirmButtonText: this.$t('common.confirm'),
                cancelButtonText: this.$t('common.cancel'),
            }).then(() => {
                let str=this.sendDataArr.map((obj)=>{return ""+obj.id}).join(",")
                let params = new FormData();
                params.append("id", str);
                this.$postForm("delEnterOrder", params).then((res) => {
                  if(res.success){
                    this.$message.success(res.msg);
                    this.getTableData();
                  }
                });
            }).catch(() => {});
        }
      }else if (route == "enterNumber") {
        if (JSON.stringify(this.sendDataArr) == "[]"||this.sendDataArr.length!=1) {
          this.$message.warning(this.$t('common.message_warn_text'));
        } else {
            this.$refs.enterNumber.init(this.sendDataArr[0]);
        }
      }
    },
    // 获取表格数据
    getTableData(){
      this.$get("enterOrders", this.filterData).then((res) => {
        this.tableData = res.data;
        this.pageinfo = res.pageinfo;
        this.pageinfo.limit=Number(this.pageinfo.limit)
        this.sendDataArr=[]
      });
    },
    // 多选框勾选集合
    setCheckBox(data){
      this.sendDataArr=data
    },
  }
}
</script>
<style scoped lang="less">
.tableBox {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/deep/.vxe-cell{
  padding-top: 5px;
  padding-bottom: 5px;
}


.tabsBox {
  margin-bottom: 20px;
    box-sizing: border-box;
    font-size: 14px;
    color: #444;
    display: flex;
    border: 1px solid #f1f1f1;
    cursor: pointer;
    .scroll_wrapper {
        width: calc(100% - 115px);
        height: 50px;
        overflow-x: scroll;
        margin: 0 5px;
        .tabslist {
            padding: 0 10px;
            height: 100%;
            display: flex;
            align-items: center;
            gap: 10px;
            .tabsItem {
                height: 28px;
                border: 1px solid #ccc;
                box-sizing: border-box;
                border-radius: 4px;
                padding: 5px;
                display: flex;
                justify-content: center;
                align-items: center;
                white-space: nowrap; //禁止文字换行
                position: relative;
                .close-btn {
                    position: absolute;
                    top: 7px;
                    right: 5px;
                    font-size: 14px;
                }
            }
            .tabs-active {
                color: #fff;
                background-color: #6c9ee5 ;
            }
        }
    }
}

.left-btn,
.right-btn {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}
.border-left {
    border-left: 1px solid #ccc;
}
.border-right {
    border-right: 1px solid #ccc;
}
/*隐藏滚动条*/
.scroll_wrapper::-webkit-scrollbar {
    display: none;
}
</style>